package main

import (
	"fmt"
	"go-glue.googlecode.com/hg/rlglue"
)

type ParrotAgent int32

func (pa *ParrotAgent) AgentInit(taskString string) {
}
func (pa *ParrotAgent) AgentStart(obs rlglue.Observation) rlglue.Action {
	*pa = 0
	return obs
}
func (pa *ParrotAgent) AgentStep(reward float64, obs rlglue.Observation) rlglue.Action {
	(*pa)++
	return obs
}
func (pa *ParrotAgent) AgentEnd(reward float64) {
}
func (pa *ParrotAgent) AgentCleanup() {
}
func (pa *ParrotAgent) AgentMessage(message string) (reply string) {
	timesToPrint := int32(*pa) % 3
	reply = message + "|"
	for i := int32(0); i < timesToPrint; i++ {
		reply += fmt.Sprintf("%d", *pa) + "."
	}
	reply += "|" + message
	return
}
func main() {
	if err := rlglue.LoadAgent(new(ParrotAgent)); err != nil {
		panic(err)
	}
}
